package com.edu.exam.enums.examination.paper;

/**
 * 考号格式验证枚举
 *
 * @author System
 * @version 1.0.0
 */
public enum ExamNumberFormatValidation {
    VALID("VALID", "格式正确"),
    INVALID("INVALID", "格式错误"),
    PARTIAL("PARTIAL", "部分正确"),
    MISSING("MISSING", "缺失"),
    ILLEGIBLE("ILLEGIBLE", "无法识别"),
    CORRUPTED("CORRUPTED", "已损坏"),
    OVERFLOW("OVERFLOW", "超出范围"),
    UNDERFLOW("UNDERFLOW", "低于范围"),
    SPECIAL_CHAR("SPECIAL_CHAR", "包含特殊字符"),
    TOO_LONG("TOO_LONG", "过长"),
    TOO_SHORT("TOO_SHORT", "过短");

    private final String code;
    private final String description;

    ExamNumberFormatValidation(String code, String description) {
        this.code = code;
        this.description = description;
    }

    public String getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }

    public static ExamNumberFormatValidation fromCode(String code) {
        for (ExamNumberFormatValidation validation : ExamNumberFormatValidation.values()) {
            if (validation.code.equals(code)) {
                return validation;
            }
        }
        throw new IllegalArgumentException("Unknown exam number format validation code: " + code);
    }

    @Override
    public String toString() {
        return description;
    }
}
